﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;
using NickLee.Common;
using System.Text;

namespace GPCSC.Web
{
    public partial class main : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                f_load();
                bulidqy();
                bulidnc();
                Buildsq();

                buildtable();//绑定解决
                buildtable1();
                buildtable2();

                buildtables();//绑定问题
                buildtable1s();
                buildtable2s();


            }
        }
        protected void f_load()
        {
            byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
            Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
      
            Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
            this.ld.Text = users.REALNAME;
            this.dw.Text = users.POSTName;
            this.zw.Text = users.DepartName; ;
        }
        #region 挂钩
        protected void bulidqy()
        {
            Hashtable htable = new Hashtable();
            htable.Add("@value", "2");
            GPCSC.Web.DataReturn da = new DataReturn();
            DataSet ds = da.ReturnData(htable, "sel_xdfas_all");
            ggqy.DataSource = ds;
            ggqy.DataBind();

        }
        protected void bulidnc()
        {
            Hashtable htable = new Hashtable();
            htable.Add("@value", "1");
            GPCSC.Web.DataReturn da = new DataReturn();
            DataSet ds = da.ReturnData(htable, "sel_xdfas_all");
            ggnc.DataSource = ds;
            ggnc.DataBind();
        }
        protected void Buildsq()
        {
            Hashtable htable = new Hashtable();
            htable.Add("@value", "3");
            GPCSC.Web.DataReturn da = new DataReturn();
            DataSet ds = da.ReturnData(htable, "sel_xdfas_all");
            Repeater1.DataSource = ds;
            Repeater1.DataBind();
        }
        #endregion

        #region  解决
        protected void buildtable()
        {
            try
            {
                Hashtable htable = new Hashtable();

                GPCSC.Web.DataReturn da = new DataReturn();

                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);

                Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                htable.Add("@lgid", users.CL_USER_SOID.ToString());

                htable.Add("@juvalue", "2");

                DataSet ds = da.ReturnData(htable, "sel_jutable_all");

                Repeater2.DataSource = cuttitle(ds,"2");
                Repeater2.DataBind();
            }
            catch (Exception ee)
            {
                throw ee;
            }

        }

        protected void buildtable1()
        {
            try
            {
                Hashtable htable = new Hashtable();

                GPCSC.Web.DataReturn da = new DataReturn();

                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);

                Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                htable.Add("@lgid", users.CL_USER_SOID.ToString());

                htable.Add("@juvalue", "1");

                DataSet ds = da.ReturnData(htable, "sel_jutable_all");

                Repeater3.DataSource = cuttitle(ds, "2");
                Repeater3.DataBind();
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }

        protected void buildtable2()
        {
            try
            {
                Hashtable htable = new Hashtable();

                GPCSC.Web.DataReturn da = new DataReturn();

                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);

                Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                htable.Add("@lgid", users.CL_USER_SOID.ToString());

                htable.Add("@juvalue", "0");

                DataSet ds = da.ReturnData(htable, "sel_jutable_all");

                Repeater4.DataSource = cuttitle(ds, "2");
                Repeater4.DataBind();
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }

        #endregion 解决

        #region  问题
        protected void buildtables()
        {
            try
            {
                Hashtable htable = new Hashtable();

                GPCSC.Web.DataReturn da = new DataReturn();

                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);

                Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                htable.Add("@lgid", users.CL_USER_SOID.ToString());

                htable.Add("@wtvalue", "2");

                DataSet ds = da.ReturnData(htable, "sel_wtstable_all");

                Repeater7.DataSource = cuttitle(ds, "1");
                Repeater7.DataBind();
            }
            catch (Exception ee)
            {
                throw ee;
            }

        }

        protected void buildtable1s()
        {
            try
            {
                Hashtable htable = new Hashtable();

                GPCSC.Web.DataReturn da = new DataReturn();

                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);

                Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                htable.Add("@lgid", users.CL_USER_SOID.ToString());

                htable.Add("@wtvalue", "1");

                DataSet ds = da.ReturnData(htable, "sel_wtstable_all");

                Repeater6.DataSource = cuttitle(ds, "1");
                Repeater6.DataBind();
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }

        protected void buildtable2s()
        {
            try
            {
                Hashtable htable = new Hashtable();

                GPCSC.Web.DataReturn da = new DataReturn();

                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);

                Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
                htable.Add("@lgid", users.CL_USER_SOID.ToString());

                htable.Add("@wtvalue", "0");

                DataSet ds = da.ReturnData(htable, "sel_wtstable_all");

                Repeater5.DataSource = cuttitle(ds, "1");
                Repeater5.DataBind();
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }

        #endregion 问题


        protected DataSet cuttitle(DataSet ds, string type)
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (type == "1")
                {
                    if (dr["wttex"].ToString().Length > 18)
                    {
                        dr["showtitles"] = dr["wttex"].ToString().Substring(0, 18)+"......";
                    }
                    else
                    {
                        dr["showtitles"] = dr["wttex"].ToString();
                    }
                }
                else
                {
                    if (dr["jutext"].ToString().Length > 18)
                    {
                        dr["showtitles"] = dr["jutext"].ToString().Substring(0, 18)+"......";
                    }
                    else
                    {
                        dr["showtitles"] = dr["jutext"].ToString();
                    }
                }
                
            }
            return ds;
        }
    }
}